<template>
    <el-pagination
        v-if="totalNum"
        @current-change="handleCurrentChange"
        :current-page="current ? current : 1"
        :page-size="pageSizes"
        :layout="layouts"
        :total="totalNum"
        background
        :style="{ textAlign: position ? position : $setTing.paging.direction }"
    >
    </el-pagination>
</template>

<script>
import setTing from '../appSetting'
export default {
    name: 'pagination',
    props: ['totalNum', 'current', 'pageSize', 'position'],
    data() {
        return {
            currentPage: this.current,
            pageSizes: this.pageSize ? this.pageSize : setTing.paging.pageSize,
            layouts: 'prev, pager, next'
        }
    },
    mounted() {},
    methods: {
        handleCurrentChange(val) {
            // currentPage 改变时触发，向父组件传递参数,父组件pageNum的值为val
            this.$emit('paginaClick', val)
        }
    }
}
</script>

<style scoped>
.el-pagination {
    margin-top: 20px;
}
</style>
